<template>
	<view class="qq-box" @click="qq">
		<view class="img">

		</view>
		<view class="text">
			QQ客服
		</view>
	</view>
</template>

<script>
	import {
		http
	} from '@/api/index.js'
	export default {
		data() {
			return {
				qqNumber: ""
			}
		},
		methods: {
			//获取网站配置
			getSetting() {
				http.post('/api/index/getSetting').then(res => {
					document.documentElement.style.setProperty('--bg-color', res.theme_color);
					document.documentElement.style.setProperty('--text-color', res.font_color);
					this.qqNumber = res.qq
				}).catch(err => {
					console.log(err);
				})
			},
			qq() {
				this.getSetting()
				// 判断是否PC端访问
				var isMobile = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent);
				if (!isMobile) {
					const url = `tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin=${this.qqNumber}`
					console.log(url);
					window.open(url, '_blank')
				} else {
					const url = `mqqwpa://im/chat?chat_type=wpa&uin=${this.qqNumber}&version=1&src_type=web`;
					console.log(url);
					window.location.href = url;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.qq-box {
		width: 100rpx;
		height: 150rpx;
		background-color: rgba(0, 0, 0, 0.6);
		position: absolute;
		right: 10rpx;
		bottom: 200rpx;
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-evenly;

		.img {
			width: 90rpx;
			height: 90rpx;
			background-image: url("../static/index/QQ.png");
			background-size: contain;
			background-position: center;
			background-repeat: no-repeat;
		}

		.text {
			width: 100%;
			font-size: 24rpx;
			white-space: nowrap;
			color: white;
			text-align: center;
		}
	}
</style>